package com.ruicar.afs.cloud.apply.common.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruicar.afs.cloud.common.core.entity.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @description: 联系人信息表
 * @author: sijun.yu
 * @date: 2020/5/11 18:13
 */
@Data
@TableName(value = "apply_cust_contacts", autoResultMap = true)
@Accessors(chain = true)
public class ApplyCustContacts extends BaseEntity<ApplyCustContacts> {

    /**
     * 申请编号
     */
    private String applyNo;
    /**
     * 与申请人关系
     */
    private String custRelation;
    /**
     * 姓名
     */
    private String custName;
    /**
     * 手机号码
     */
    private String telPhone;
    /**
     * 证件类型
     */
    private String certType;
    /**
     * 证件号码
     */
    private String certNo;
    /**
     * 公司名称
     */
    private String companyName;
    /**
     * 公司电话
     */
    private String companyPhone;
    /**
     * 月收入
     */
    private Double monthlyIncome;
    /**
     * 现居住地-省份
     */
    private String livingProvince;
    /**
     * 现居住地-城市
     */
    private String livingCity;
    /**
     * 现居住地-区县
     */
    private String livingCounty;
    /**
     * 现居住地-街道
     */
    private String livingStreet;
    /**
     * 现居住地-详细
     */
    private String detailAddress;

    @TableField(exist = false)
    private String[] detailAddressTemp;
    /**
     * 数据是否锁住
     */
    private String isLock;
    /**
     * 现居住地址
     */
    @TableField(exist = false)
    private String livingDetailAddress;

    public String[] getDetailAddressTemp() {
        return new String[]{this.livingProvince, this.livingCity, this.livingCounty, this.livingStreet};
    }

    public void setDetailAddressTemp(String[] detailAddressTemp) {
        //关于获取省市区数组时，下标判断，以防出现数组越界
        if (detailAddressTemp.length >= 1) {
            if ("undefined".equals(detailAddressTemp[0])) {
                this.livingProvince = "";
            } else {
                this.livingProvince = detailAddressTemp[0];
            }
        }
        if (detailAddressTemp.length >= 2) {
            if ("undefined".equals(detailAddressTemp[1])) {
                this.livingCity = "";
            } else {
                this.livingCity = detailAddressTemp[1];
            }
        }
        if (detailAddressTemp.length >= 3) {
            this.livingCounty = detailAddressTemp[2];
        }
        if (detailAddressTemp.length >= 4) {
            this.livingStreet = detailAddressTemp[3];
        }
        this.detailAddressTemp = detailAddressTemp;
    }
}
